home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / test.zip / TEST.MAN < prev   
Text File  |  1994-04-14  |  3KB  |  97 lines

  1. TEST(1V)        BATCH UTILITIES            TEST(1V)
  2.  
  3. NAME
  4.     test - returns true or false according to a conditional
  5.     expression.
  6.  
  7. AUTHOR
  8.         Jason Mathews
  9.     NASA/Goddard Space Flight Center
  10.     <mathews@nssdca.gsfc.nasa.gov>
  11.  
  12. CATEGORY
  13.     MS-DOS Batch utility - test file/directory status
  14.  
  15. SYNOPSIS
  16.     syntax:  test <expression>
  17.  
  18. DESCRIPTION
  19.     test evaluates the expression <expression> and, if its value
  20.     is true, returns a non-zero (true) exit status; otherwise, a
  21.     zero (false) exit status is returned.  test returns a
  22.     zero if there are no arguments.
  23.  
  24. USAGE
  25.  
  26.  The following primitives are used to construct an expression.
  27.  
  28.  primitive operators testing one file:
  29.  
  30.       -f|b|c|e|d|s|z|r|w|x filename
  31.  
  32.    -e  true if filename exists
  33.    -b  true if filename exists and is a block special device
  34.    -c  true if filename exists and is a character special device
  35.    -d  true if filename exists and is a directory
  36.    -f  true if filename exists and is a regular file
  37.    -s  true if filename exists and has a size greater than zero
  38.    -z  true if filename exists and has a zero length (empty)
  39.    -r  true if filename exists and is readable
  40.    -w  true if filename exists and is writable
  41.    -x  true if filename exists and is executable
  42.     (MS-DOS: file extension = .COM, .EXE, .BAT, or .BTM )
  43.  
  44.    -m[n] filename
  45.       True if filename exists and has been modified in n days (default=1).
  46.  
  47.  primitive operators comparing two files:
  48.  
  49.       -D|N|S file1 file2
  50.  
  51.    -D  true of file1 has same date as file2 and both files exist
  52.    -N  true if file1 is newer than file2 and both files exist
  53.    -S  true if file1 has same size as file2 and both files exist
  54.  
  55.  Logical operators:
  56.  
  57.  The above primitives may be combined with the following operators:
  58.  
  59.   cond1 [-a] cond2  True if both cond1 and cond2 are true.
  60.             The -a is not required.  It is implied by
  61.             the juxtaposition by the two conditions.
  62.  
  63.   cond1 -o cond2    True if either cond1 or cond2 is true
  64.             (-o is the OR operator).
  65.  
  66.   ! condition       True if the condition is false
  67.             (! is the unary NOT operator).
  68.  
  69.  AND/OR/NOT operators are processed left to right with no precedence;
  70.  e.g. "! c1 -o c2 -a c3" is evaluated as (!c1 -o c2) -a c3.
  71.  
  72.   return errorlevel = 1 if the tested expression is true
  73.   otherwise return 0 (conditions not meet or error flag set).
  74.  
  75. EXAMPLES
  76.  
  77. Test if c:\dos directory exists and autoexec.bat has been modified
  78. within last 7 days.
  79.  
  80.     test -d c:\dos -m7 autoexec.bat
  81.  
  82. Test if image.dat has been modified today, in which case we
  83. want to skip the update section.
  84.  
  85.     test -m image.dat
  86.     if errorlevel 1 goto skip_update
  87.     ... update_file_here ...
  88.     :skip_update
  89.     ...
  90.  
  91. Test if file has zero length or file has write access.
  92.  
  93.     test -z myfile -o -w myfile
  94.  
  95.  
  96. MS-DOS Release 1.3    Last Change: 14 April 1994
  97.